﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.model.Instance;
using l1cs.server.utils;
using l1cs.server.serverpackets;

namespace l1cs.server.clientpackets
{
    public class C_Trade : ClientBasePacket
    {
        private const String _C_TRADE = "[C] C_Trade";
        private static Logger _log = Logger.getLogger( typeof( C_Trade ).FullName );

        public C_Trade( byte[] abyte0, ClientThread clientthread )
            : base( abyte0 )
        {

            L1PcInstance player = clientthread.getActiveChar();
            if ( player.isGhost() )
            {
                return;
            }
            L1PcInstance target = FaceToFace.faceToFace( player );
            if ( target != null )
            {
                if ( !target.isParalyzed() )
                {
                    player.setTradeID( target.getId() ); // 相手のオブジェクトIDを保存しておく
                    target.setTradeID( player.getId() );
                    target.sendPackets( new S_Message_YN( 252, player.getName() ) ); // %0%sがあなたとアイテムの取引を望んでいます。取引しますか？（Y/N）
                }
            }
        }

        override
        public String getType()
        {
            return _C_TRADE;
        }
    }
}
